<?php		




class MongoScript extends ScriptBase{


	/**
	 * 构造函数，初始化插件
	 */
	public function __construct() {

	}


	public function index(){

		
		
	}
	public function datamodify(){
		$db = n_api("mongo")->db001;
		$bigData = $db->collection("big_data");
		$data = $bigData->find();
		$i = 0;
		foreach ($data as $key => $val) {
			$bigData->update(array("_id"=>$val['_id']),array('$set'=>array("id"=>++$i)));
			// print_r($val);exit;
		}
	}	
	public function showdown(){
		$mg = new MyMongo('admin');
		$mg->db()->command(array("shutdown"=>1));
		
	}
	public function zgzTest(){
		// echo '==';
		$db = n_api("mongo")->zgz;
		//$db->insert("stat",array("id"=>10,"content"=>"teststsetsetsetsetset"));
		// $db->insert("stat",array("content"=>"teststsetsetsetsetset"));
		// $db->insert("stat",array("content"=>"teststsetsetsetsetset"));
		// print_r($db);
		// $db->insert("stat","test,test,test,test");
		// $db->insert("stat","test,test,test,test");
// 		
		$rs = $db->get("stat",'10');
		print_r($rs);
	}

	public function testmongo(){

		echo "testmongo";

		$data = array(0=>array("rule"=>"phrase","name"=>"lishaohui"),1=>array("rule"=>"idip","name"=>"lishaohui"));


		$db = n_api('mongo')->stat;

		echo $db->batchInsert('sohufocusbbs',$data);
	}

}